package com.hsmpay.mobile.dao.terminal.impl;

import com.hsmpay.common.dao.Impl.BaseDaoSupport;
import com.hsmpay.mobile.dao.terminal.TchannelDao;
import com.hsmpay.mobile.pojo.terminal.Tchannel;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;

/**
 * 终端通道 dao接口
 */
@Repository("tchannelDao")
public class TchannelDaoImpl extends BaseDaoSupport<Tchannel, Long> implements TchannelDao<Tchannel, Long> {

    /**
     * 根据终端代码  查询通道
     *
     * @param code
     * @return
     * @throws SQLException
     */
    public Tchannel searchMobileTchannelByCode(Integer code) throws SQLException {
        Tchannel tchannel = new Tchannel();
//		tchannel.setClientType(2);
        tchannel.setCode(code);
        tchannel.setSearchParam(" AND (TC.CLIENTTYPE = 2 OR TC.CLIENTTYPE = 8)");
        return searchEntity(tchannel);
    }

    /**
     * 更新code 修改更新第三方参数
     *
     * @param code
     * @param otherParam
     * @return
     * @throws Exception
     */
    public int updateMobileTcOtherByCode(Integer code, String otherParam) throws SQLException {
        Tchannel tchannel = new Tchannel();
        tchannel.setClientType(2);
        tchannel.setCode(code);
        tchannel.setOtherParam(otherParam);
        return getSqlMapClientTemplate().update("tchannelSqlMap.updateMobileTcOtherByCode", tchannel);
    }
}